using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Manager : MonoBehaviour
{
    public GameObject viewport;
    public GameObject onlinelist;
    
    Client client = new Client();
    Message message = new Message();

    // Start is called before the first frame update
    void Start()
    {
        try
        {
            client.Connect("127.0.0.1", 2333);
        }
        catch
        {
            Debug.Log("服务器未上线");
        }

        viewport.GetComponent<ScrollController>().Message = message;
        onlinelist.GetComponent<OnLineListController>().Message = message;
        message.Client = client;
        client.StartReceiveThread();
        client.Message = message;

    }

    // Update is called once per frame
    void Update()
    {

    }
    
    public void onclick()
    {
        message.SendName(name);
    }
    
    
    public void CloseConnect () 
    {
        try
        {
            client.ShutDown();
        }
        finally
        {
            client.Close();
        }
        //UnityEditor.EditorApplication.isPlaying = false;
        Application.Quit();
    }


}
